unit PlugIn;

{$mode objfpc}{$H+}

interface

uses
  BW_CustObj,
  BW_CustomObj_Acc,
  BW_Handler,
  BW_Host,
  BW_Global,

  LW_Host  ,
  LW_Types ,
  LW_XPanel;

type

  { TBasicBarn }

  TBasicBarn = class(TCustomObject)
  private
    const
      FVert : array [0..9] of TLWDVector =
      (
        (0.0,  0.0,  0.0),
        (1.0,  0.0,  0.0),
        (1.0,  1.0,  0.0),
        (0.5,  1.5,  0.0),
        (0.0,  1.0,  0.0),
        (0.0,  0.0, -1.0),
        (1.0,  0.0, -1.0),
        (1.0,  1.0, -1.0),
        (0.5,  1.5, -1.0),
        (0.0,  1.0, -1.0)
      );
      FEdge : array [0..16, 0..1] of Integer =
      (
        (0, 1),  (1, 2),  (2, 3),  (3, 4),  (4, 0),  (5, 6),  (6, 7),  (7, 8),
        (8, 9),  (9, 5),  (0, 5),  (1, 6),  (2, 7),  (3, 8),  (4, 9),  (1, 4),
        (0, 2)
      );

  public
    procedure Initialize; override;
    procedure Finalize; override;

    function  SetDescription : String       ; override;

    procedure Evaluate       ;                override;
    function  SetFlags       : TCustObjFlags; override;

    function  BuildXPanels : PLWXPanel; override;
  end;

implementation

uses
  Dialogs, sysutils;

var
  BasicBarn : TCustomObject;

{ TBasicBarn }

procedure TBasicBarn.Initialize;
begin
end;

procedure TBasicBarn.Finalize;
begin
end;

function  TBasicBarn.SetDescription : String       ;
begin
  Result := 'Basic Barn';
end;

procedure TBasicBarn.Evaluate       ;
var
  Index : Integer;
begin
  with Painter do
  begin

    CoordSys := csObject;

    for Index := 0 to 14 do
    begin
      DrawLine(FVert[FEdge[Index, 0]], FVert[FEdge[Index, 1]]);
    end;

    LinePattern := lpDot;

    for Index := 15 to 16 do
      DrawLine(FVert[FEdge[Index, 0]], FVert[FEdge[Index, 1]]);

  end;
end;

function  TBasicBarn.SetFlags       : TCustObjFlags;
begin
  Result := [];
end;

function TBasicBarn.BuildXPanels : PLWXPanel;
begin
  TMessage(GetGlobal(gtMessage)).Info('No GUI yet!');

  Result := nil;
end;

initialization
  BasicBarn := TBasicBarn.Create('BasicBarn', [htWithXPanels]);

finalization
  BasicBarn.Free;

end.

